#ifndef UIOFVIEWER_H
#define UIOFVIEWER_H

#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QFrame>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLCDNumber>
#include <QtWidgets/QLabel>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QRadioButton>
#include <QtWidgets/QSpacerItem>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QWidget>
#include <QResource>
#include <qwt_knob.h>
#include <qwt_plot.h>
#include "plot.h"
#include "wheelbox.h"

QT_BEGIN_NAMESPACE

class UiOfDataViewer
{
public:
	virtual ~UiOfDataViewer()
	{
		delete[] plot;
		delete[] label_vlaue;
		delete[] lcd_vlaue;
	}
protected:
	QHBoxLayout *hl_form;
	QVBoxLayout *vl_plot;
	QVBoxLayout *vl_in_para;
	QHBoxLayout *hl_para;
	QPushButton* bn_hide;
	QFrame* fra_para;
	QFrame* fra_value;
	QVBoxLayout *vl_value;
	QSpacerItem *vs_blank;
	QSpacerItem *vs_blank1;
	QSpacerItem *vs_blank3;
	QSpacerItem *vs_blank4;
	QFrame *fra_zoom;
	QVBoxLayout *vl_zoom;
	QRadioButton *rb_key_zoom;
	QRadioButton *rb_wheel_zoom;
	QPushButton *bn_pause;
	QPushButton* bn_auto;
	WheelBox* wb_xrange;
	Plot** plot;
	QLabel** label_vlaue;
	QLCDNumber** lcd_vlaue;
	QFrame* fra_feq;
	QVBoxLayout* vl_feq;
	QLabel* label_feq;
	QLCDNumber* lcd_feq;
	QLabel* label_save;
	UiOfDataViewer(QWidget *data_viewer, int num_plot)
	{
		plot = new Plot*[num_plot];
		label_vlaue = new QLabel*[num_plot];
		lcd_vlaue = new QLCDNumber*[num_plot];
		setupUi(data_viewer, num_plot);
	}
	void setupUi(QWidget *data_viewer, int num_plot)
	{

		data_viewer->resize(700, 400);
		hl_form = new QHBoxLayout(data_viewer);
		hl_form->setSpacing(3);
		hl_form->setContentsMargins(2, 2, 2, 2);
		hl_form->setObjectName(QStringLiteral("hl_form"));
		hl_form->setSizeConstraint(QLayout::SetMinAndMaxSize);
		vl_plot = new QVBoxLayout();
		vl_plot->setSpacing(3);
		vl_plot->setObjectName(QStringLiteral("vl_plot"));

		for (int i = 0; i < num_plot; i++)
		{
			plot[i] = new Plot(data_viewer);
			
			plot[i]->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
			plot[i]->setMinimumWidth(250);
			vl_plot->addWidget(plot[i]);
		}
		hl_form->addLayout(vl_plot);

		hl_para = new QHBoxLayout();
		hl_para->setSpacing(2);
		hl_para->setContentsMargins(0, 0, 0, 0);
		hl_form->addLayout(hl_para);

		bn_hide = new QPushButton(data_viewer);
		bn_hide->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred);
		bn_hide->setMinimumWidth(10);
		bn_hide->setFlat(true);
		bn_hide->setCursor(QCursor(Qt::PointingHandCursor));
		hl_para->addWidget(bn_hide);

		fra_para = new QFrame(data_viewer);
		fra_para->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
		fra_para->setMaximumWidth(100);

		vl_in_para = new QVBoxLayout(fra_para);
		vl_in_para->setSpacing(10);
		vl_in_para->setObjectName(QStringLiteral("vl_in_para"));
		vl_in_para->setContentsMargins(0, 0, 0, 0);

		vs_blank3 = new QSpacerItem(20, 15, QSizePolicy::Preferred, QSizePolicy::Fixed);
		vl_in_para->addItem(vs_blank3);

		wb_xrange = new WheelBox(QApplication::tr("Time Length(s)"), 1.0, 100.0, 1.0, fra_para);
		wb_xrange->setObjectName(QStringLiteral("wl_xrange"));
		wb_xrange->setValue(10);
		wb_xrange->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
		wb_xrange->setMinimumSize(QSize(0, 80));
		vl_in_para->addWidget(wb_xrange);

		QFont font;
		font.setFamily(QString::fromUtf8("\345\256\213\344\275\223"));
		font.setPointSize(9);
		QPalette pal(Qt::black);
		pal.setColor(QPalette::WindowText, Qt::green);

		fra_feq = new QFrame(fra_para);
		fra_feq->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);

		vl_feq = new QVBoxLayout(fra_feq);
		vl_feq->setSpacing(5);
		vl_feq->setContentsMargins(0, 0, 0, 0);
		label_feq = new QLabel(fra_feq);
		label_feq->setFont(font);
		vl_feq->addWidget(label_feq);
		lcd_feq = new QLCDNumber(fra_feq);
		lcd_feq->setPalette(pal);
		lcd_feq->setAutoFillBackground(true);
		lcd_feq->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
		lcd_feq->setMinimumSize(QSize(0, 30));
		lcd_feq->setDigitCount(8);
		lcd_feq->setSegmentStyle(QLCDNumber::Flat);
		vl_feq->addWidget(lcd_feq);
		vl_in_para->addWidget(fra_feq);

		fra_value = new QFrame(fra_para);
		fra_value->setObjectName(QStringLiteral("fra_value"));
		fra_value->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
		fra_value->setMinimumSize(QSize(0, 0));
        fra_value->setFrameShape(QFrame::NoFrame);
		fra_value->setFrameShadow(QFrame::Raised);
		vl_value = new QVBoxLayout(fra_value);
		vl_value->setSpacing(5);
		vl_value->setContentsMargins(3, 3, 3, 3);
		vl_value->setObjectName(QStringLiteral("vl_value"));
		vl_value->setContentsMargins(0, 0, 0, 0);


		for (int i = 0; i < num_plot; i++)
		{  
			label_vlaue[i] = new QLabel(fra_value);
			label_vlaue[i]->setFont(font);
			vl_value->addWidget(label_vlaue[i]);
			lcd_vlaue[i] = new QLCDNumber(fra_value);
			lcd_vlaue[i]->setPalette(pal);
			lcd_vlaue[i]->setAutoFillBackground(true);
			lcd_vlaue[i]->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
			lcd_vlaue[i]->setMinimumSize(QSize(0, 30));
			lcd_vlaue[i]->setDigitCount(8);
			lcd_vlaue[i]->setSegmentStyle(QLCDNumber::Flat);
			vl_value->addWidget(lcd_vlaue[i]);
		}

		vs_blank1 = new QSpacerItem(20, 40, QSizePolicy::Preferred, QSizePolicy::Expanding);
		vl_value->addItem(vs_blank1);

		vl_in_para->addWidget(fra_value);

		vs_blank = new QSpacerItem(20, 40, QSizePolicy::Preferred, QSizePolicy::Expanding);
		vl_in_para->addItem(vs_blank);

		label_save = new QLabel(fra_para);
		vl_in_para->addWidget(label_save);

		fra_zoom = new QFrame(fra_para);
		fra_zoom->setEnabled(false);
		fra_zoom->setObjectName(QStringLiteral("fra_zoom"));
		fra_zoom->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
		fra_zoom->setMinimumSize(QSize(0, 60));
        fra_zoom->setFrameShape(QFrame::NoFrame);
		fra_zoom->setFrameShadow(QFrame::Raised);
		vl_zoom = new QVBoxLayout(fra_zoom);
		vl_zoom->setSpacing(3);
		vl_zoom->setContentsMargins(11, 11, 11, 11);
		vl_zoom->setObjectName(QStringLiteral("vl_zoom"));
		vl_zoom->setContentsMargins(0, 0, 0, 0);
		rb_key_zoom = new QRadioButton(fra_zoom);
		rb_key_zoom->setObjectName(QStringLiteral("rb_key_zoom"));
		vl_zoom->addWidget(rb_key_zoom);

		rb_wheel_zoom = new QRadioButton(fra_zoom);
		rb_wheel_zoom->setChecked(true);
		rb_wheel_zoom->setObjectName(QStringLiteral("rb_wheel_zoom"));
		vl_zoom->addWidget(rb_wheel_zoom);

		vl_in_para->addWidget(fra_zoom);

		bn_auto = new QPushButton(fra_para);
		bn_auto->setObjectName(QStringLiteral("bn_pause"));
		bn_auto->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
		bn_auto->setMinimumSize(QSize(0, 40));
		bn_auto->setSizeIncrement(QSize(0, 0));
		vl_in_para->addWidget(bn_auto);

		bn_pause = new QPushButton(fra_para);
		bn_pause->setObjectName(QStringLiteral("bn_pause"));
		bn_pause->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
		bn_pause->setMinimumSize(QSize(0, 40));
		bn_pause->setSizeIncrement(QSize(0, 0));
		vl_in_para->addWidget(bn_pause);

		vs_blank3 = new QSpacerItem(20, 15, QSizePolicy::Preferred, QSizePolicy::Fixed);
		vl_in_para->addItem(vs_blank3);

		hl_para->addWidget(fra_para);
		hl_form->setStretch(0, 5);


		retranslateUi(data_viewer);

		QMetaObject::connectSlotsByName(data_viewer);
	} // setupUi

	void retranslateUi(QWidget *data_viewer)
	{
		label_feq->setText(QApplication::tr("Frequency(Hz)"));
		rb_key_zoom->setText(QApplication::tr("Button Zoomer"));
		rb_wheel_zoom->setText(QApplication::tr("Wheel Zoomer"));
		bn_auto->setText(QApplication::tr("Automation"));

		label_save->setText(QApplication::tr("<html><head/><body><p><a href=\"jia_link\"><span style=\" font-size:10pt; font-style:italic; text-decoration: underline; color:#0000ff;\">save data</span></a></p></body></html>"));
	} // retranslateUi

};

QT_END_NAMESPACE

#endif // UIOFVIEWER_H




